﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace work_of_jump_100
{
    public partial class FrmMain : Form
    {
        //游戏对象说明
        private Game _game;

        public FrmMain()
        {
            InitializeComponent();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void gameArea_Load(object sender, EventArgs e)
        {
            //初始化游戏类
            _game = new Game();
            _game.gameChanged += _game_gameChanged;
            this.timer1.Interval = 1;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void _game_gameChanged()
        {
            if (_game != null)//游戏已经初始化了
            {
                gameArea.Invalidate();

            }
        }

        private void ganeArea_Paint(object sender, PaintEventArgs e)
        {
            if (_game != null)//游戏已经初始化了
            {
                _game.Draw(e.Graphics, this.gameArea.Size);
            }
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {

        }

        private void FrmMain_KeyDown(object sender, KeyEventArgs e)
        {
             if (_game != null)//游戏已经初始化了
            {
                //传递按键值给game
                _game.KeyDown(e.KeyCode.ToString());
                gameArea.Invalidate();

            }
        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {

            
        }

        private void timer2_Tick(object sender, EventArgs e)
        {

        }


    }
}
